<?php
/**
 * Created by PhpStorm.
 * User: Sunwu
 * Date: 2017/9/21
 * Time: 9:36
 */
header('content-type:text/html;charset=utf-8');
echo "用户信息：<br><pre>";
require_once "./Curl.class.php";
require_once "./WeChatUserInfo.class.php";
$appid='wxfe7927ebbe6ef42a';
$secret="71e8bdc64676dabf34cbe3c1b2e74413";
/*//var_dump($_GET);
$code=$_GET['code'];//用户点授权后获得的code
//获取网页access_token
$webAccessTokenAPI="https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appid&secret=$secret&code=$code&grant_type=authorization_code";
$webAccessTokenAPIRes=Curl::doGet($webAccessTokenAPI);
$webAccessTokenAPIRes=json_decode($webAccessTokenAPIRes,true);
//var_dump($webAccessTokenAPIRes);
$accessToken=$webAccessTokenAPIRes['access_token'];
$openId=$webAccessTokenAPIRes['openid'];
//var_dump($accessToken);

//获取用户信息 https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
$userInfoAPI="https://api.weixin.qq.com/sns/userinfo?access_token=$accessToken&openid=$openId&lang=zh_CN";
$userInfoAPIRes=Curl::doGet($userInfoAPI);
$userInfo=json_decode($userInfoAPIRes);
var_dump($userInfo);*/

$userObject=new WeChatUserInfo($appid,$secret);
$res=$userObject->getUserInfo();
var_dump($res);